<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true">
      <el-form-item label="">
        <el-select
          filterable
          v-model="queryParams.railwayId"
          placeholder="线名"
          clearable
          style="width: 140px"
        >
          <el-option
            v-for="dict in railwayNamearr"
            :key="dict.railwayName"
            :label="dict.railwayName"
            :value="dict.railwayId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="">
        <el-select
          filterable
          v-model="queryParams.progressTypeId"
          placeholder="上下行"
          clearable
          style="width: 140px"
        >
          <el-option
            v-for="dict in progressTypearr"
            :key="dict.progressType"
            :label="dict.progressType"
            :value="dict.progressTypeId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="" class="formitemcla">
        <el-input
          v-model="queryParams.startMileageNumber"
          placeholder="起点里程"
          clearable
          style="width: 140px"
          type="number"
        >
          <template #suffix> km </template>
        </el-input>
      </el-form-item>
      <el-form-item label="~">
        <el-input
          v-model="queryParams.endMileageNumber"
          placeholder="终点里程"
          clearable
          style="width: 140px"
          type="number"
        >
          <template #suffix> km </template>
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleQuery" style="width: 90px"
          >查询</el-button
        >
        <el-button @click="resetQuery" style="width: 90px">重置</el-button>
        <el-button type="primary" style="width: 90px" @click="handleExport"
          >导出</el-button
        >
        <el-button type="primary" @click="handleAdd" style="width: 90px"
          >新增</el-button
        >
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="drainageList"
      height="62vh"
      border
      @selection-change="selectiontab"
    >
      <el-table-column type="selection" label="全选" width="50" />
      <!-- <el-table-column label="单位id" prop="unitId" />
      <el-table-column label="线路id" prop="railwayId" />
      <el-table-column label="行别id" prop="progressTypeId" /> -->

      <el-table-column label="线名" prop="railwayName" />
      <el-table-column label="上下行" prop="progressType" />
      <el-table-column label="起点里程" prop="startMileage" />
      <el-table-column label="终点里程" prop="endMileage" />
      <el-table-column label="侧别" prop="sidelongType" />
      <!-- <el-table-column label="是否并行" prop="parallelOrNot" /> -->
      <el-table-column label="排水沟类型" prop="drainageDitchType" />
      <el-table-column label="结构类型" prop="structureType" />
      <!-- <el-table-column label="排水坡度" prop="drainageSlopeGradient" /> -->
      <el-table-column label="水沟深度" prop="drainageDeepness" />
      <!-- <el-table-column label="挡墙埋深" prop="parapetDeepness" />
      <el-table-column label="挡墙宽度" prop="parapetWidth" />
      <el-table-column label="挡墙底部宽度" prop="parapetBottomWidth" />
      <el-table-column label="强度" prop="strength" />
      <el-table-column label="根底垫层-宽" prop="subcrustWidth" />
      <el-table-column label="根底垫层-厚" prop="subcrustThickness" />
      <el-table-column label="轴线偏位" prop="offsetAxis" />
      <el-table-column label="沟底局程" prop="ditchBottomExtent" />
      <el-table-column label="墙面顺直度" prop="wallStraightness" />
      <el-table-column label="墙面坡度" prop="wallSlopeGradient" />
      <el-table-column label="断面尺寸" prop="crossSectionSize" />
      <el-table-column label="铺砌厚度" prop="paveThickness" />
      <el-table-column label="外观" prop="aspect" />
      <el-table-column label="建成年月" prop="completionDate" />
      <el-table-column label="健康值" prop="healthIndex" />
      <el-table-column label="隐患等级" prop="hiddenDangerLevel" />
      <el-table-column label="设备使用频率" prop="equipmentUsageFrequency" />
      <el-table-column label="设备综合效率(OEE)" prop="oee" />
      <el-table-column label="平均无故障工作时间(MTBF)" prop="mtbf" />
      <el-table-column label="平均修复时间(MTTR)" prop="mttr" />
      <el-table-column label="区段" prop="zone" />
      <el-table-column label="工区" prop="workArea" />
      <el-table-column label="人员" prop="user" />
      <el-table-column label="备注" prop="remark" /> -->
      <el-table-column label="直接数据" min-width="110">
        <template #default="scope" class="buttontext">
          <el-button link type="primary" @click="handleUpdate(scope.row)"
            >参数</el-button
          >
          <el-button link type="primary" @click="meansFun(scope.row)"
            >资料</el-button
          >
        </template>
      </el-table-column>
      <el-table-column label="关联数据" min-width="210">
        <template #default="scope" class="buttontext">
          <el-button link type="primary" @click="resumeUpdate(scope.row)"
            >作业履历</el-button
          >
          <el-button link type="primary" @click="deviceProblem(scope.row)"
            >设备问题</el-button
          >
          <el-button link type="primary" @click="businessFinance(scope.row)"
            >业财</el-button
          >
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="70">
        <template #default="scope" class="buttontext">
          <el-button link type="primary" @click="handleDelete(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
      draggable
      title="资料"
      v-model="meansopen"
      width="1300px"
      append-to-body
      @close="closefun"
    >
      <means :forma="formam" parentName="正线排水" v-if="meansopen"></means>
    </el-dialog>
    <!-- 添加或修改正线轨道设备-附属设备-排水设备信息对话框 -->
    <el-dialog
      :title="title"
      v-model="open"
      width="1200px"
      append-to-body
      draggable
    >
      <el-form
        ref="form"
        :model="forma"
        :rules="rules"
        label-width="100px"
        :inline="true"
      >
        <div class="divflex">
          <span class="leftx"></span>
          <span class="mainz">位置</span>
          <span class="rightx"></span>
        </div>
        <el-form-item label="单位名称" prop="unitId">
          <el-select
            filterable
            clearable
            style="width: 180px"
            v-model="forma.unitId"
            placeholder="请选择"
          >
            <el-option
              v-for="dict in unitNameobj"
              :label="dict.unitName"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="线名" prop="railwayId">
          <el-select
            filterable
            clearable
            style="width: 180px"
            v-model="forma.railwayId"
            placeholder="请选择"
          >
            <el-option
              v-for="dict in railwayNameobj"
              :label="dict.railwayName"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="上下行" prop="progressTypeId">
          <el-select
            filterable
            clearable
            style="width: 180px"
            v-model="forma.progressTypeId"
            placeholder="请选择"
          >
            <el-option
              v-for="dict in progressTypeobj"
              :label="dict.progressType"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="起点里程" prop="startMileageNumber">
          <el-input
            @blur="updateproperyfun('起点')"
            style="width: 180px"
            type="number"
            v-model="forma.startMileageNumber"
            placeholder="请输入里程"
          />
        </el-form-item>
        <el-form-item label="终点里程" prop="endMileageNumber">
          <el-input
            @blur="updateproperyfun('终点')"
            style="width: 180px"
            type="number"
            v-model="forma.endMileageNumber"
            placeholder="请输入里程"
          />
        </el-form-item>
        <el-form-item label="侧别" prop="sidelongTypeId">
          <el-select
            filterable
            clearable
            style="width: 180px"
            v-model="forma.sidelongTypeId"
            placeholder="请选择"
          >
            <el-option
              v-for="dict in sidelongTypeobj"
              :label="dict.propertyName"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <div class="divflex">
          <span class="leftx"></span>
          <span class="mainz">特性</span>
          <span class="rightx"></span>
        </div>
        <el-form-item label="是否并行" prop="parallelOrNot">
          <el-select
            filterable
            clearable
            style="width: 180px"
            v-model="forma.parallelOrNot"
            placeholder="请选择"
          >
            <el-option
              v-for="dict in parallelOrNotobj"
              :label="dict.value"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="排水沟类型" prop="drainageDitchTypeId">
          <el-select
            filterable
            clearable
            style="width: 180px"
            v-model="forma.drainageDitchTypeId"
            placeholder="请选择"
          >
            <el-option
              v-for="dict in drainageDitchTypeobj"
              :label="dict.propertyName"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结构类型" prop="structureTypeId">
          <el-select
            filterable
            clearable
            style="width: 180px"
            v-model="forma.structureTypeId"
            placeholder="请选择"
          >
            <el-option
              v-for="dict in structureTypeobj"
              :label="dict.propertyName"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="排水坡度" prop="drainageSlopeGradient">
          <el-input
            style="width: 180px"
            type="number"
            v-model="forma.drainageSlopeGradient"
            placeholder="请输入排水坡度"
          />
        </el-form-item>
        <el-form-item label="水沟深度" prop="drainageDeepness">
          <el-input
            style="width: 180px"
            type="number"
            v-model="forma.drainageDeepness"
            placeholder="请输入水沟深度"
          />
        </el-form-item>
        <el-form-item label="挡墙埋深" prop="parapetDeepness">
          <el-input
            style="width: 180px"
            type="number"
            v-model="forma.parapetDeepness"
            placeholder="请输入挡墙埋深"
          />
        </el-form-item>
        <el-form-item label="挡墙宽度" prop="parapetWidth">
          <el-input
            style="width: 180px"
            type="number"
            v-model="forma.parapetWidth"
            placeholder="请输入挡墙宽度"
          />
        </el-form-item>
        <el-form-item label="挡墙底部宽度" prop="parapetBottomWidth">
          <el-input
            style="width: 180px"
            type="number"
            v-model="forma.parapetBottomWidth"
            placeholder="请输入挡墙底部宽度"
          />
        </el-form-item>
        <el-form-item label="强度" prop="strength">
          <el-input
            style="width: 180px"
            v-model="forma.strength"
            placeholder="请输入强度"
          />
        </el-form-item>
        <el-form-item label="根底垫层-宽" prop="subcrustWidth">
          <el-input
            style="width: 180px"
            type="number"
            v-model="forma.subcrustWidth"
            placeholder="请输入根底垫层-宽"
          />
        </el-form-item>
        <el-form-item label="根底垫层-厚" prop="subcrustThickness">
          <el-input
            style="width: 180px"
            type="number"
            v-model="forma.subcrustThickness"
            placeholder="请输入根底垫层-厚"
          />
        </el-form-item>
        <el-form-item label="轴线偏位" prop="offsetAxis">
          <el-input
            style="width: 180px"
            v-model="forma.offsetAxis"
            placeholder="请输入轴线偏位"
          />
        </el-form-item>
        <el-form-item label="沟底局程" prop="ditchBottomExtent">
          <el-input
            style="width: 180px"
            v-model="forma.ditchBottomExtent"
            placeholder="请输入沟底局程"
          />
        </el-form-item>
        <el-form-item label="墙面顺直度" prop="wallStraightness">
          <el-input
            style="width: 180px"
            v-model="forma.wallStraightness"
            placeholder="请输入墙面顺直度"
          />
        </el-form-item>
        <el-form-item label="墙面坡度" prop="wallSlopeGradient">
          <el-input
            style="width: 180px"
            type="number"
            v-model="forma.wallSlopeGradient"
            placeholder="请输入墙面坡度"
          />
        </el-form-item>
        <el-form-item label="断面尺寸" prop="crossSectionSize">
          <el-input
            style="width: 180px"
            v-model="forma.crossSectionSize"
            placeholder="请输入断面尺寸"
          />
        </el-form-item>
        <el-form-item label="铺砌厚度" prop="paveThickness">
          <el-input
            style="width: 180px"
            type="number"
            v-model="forma.paveThickness"
            placeholder="请输入铺砌厚度"
          />
        </el-form-item>
        <el-form-item label="外观" prop="aspect">
          <el-input
            style="width: 180px"
            v-model="forma.aspect"
            placeholder="请输入外观"
          />
        </el-form-item>
        <el-form-item label="建成年月" prop="completionDate">
          <el-date-picker
            style="width: 180px"
            format="YYYY/MM/DD"
            value-format="YYYY/MM/DD"
            v-model="forma.completionDate"
            type="datetime"
            placeholder="请输入建成年月"
          />
        </el-form-item>
        <div class="divflex">
          <span class="leftx"></span>
          <span class="mainz">健康度</span>
          <span class="rightx"></span>
        </div>
        <el-form-item label="健康值" prop="healthIndex">
          <el-input
            style="width: 180px"
            v-model="forma.healthIndex"
            placeholder="请输入健康值"
          />
        </el-form-item>
        <el-form-item label="隐患等级" prop="hiddenDangerLevel">
          <el-input
            style="width: 180px"
            v-model="forma.hiddenDangerLevel"
            placeholder="请输入隐患等级"
          />
        </el-form-item>
        <el-form-item label="设备使用频率" prop="equipmentUsageFrequency">
          <el-input
            style="width: 180px"
            v-model="forma.equipmentUsageFrequency"
            placeholder="请输入设备使用频率"
          />
        </el-form-item>
        <el-form-item label="设备综合效率(OEE)" prop="oee">
          <el-input
            style="width: 180px"
            v-model="forma.oee"
            placeholder="请输入设备综合效率(OEE)"
          />
        </el-form-item>
        <el-form-item label="平均无故障工作时间(MTBF)" prop="mtbf">
          <el-input
            style="width: 180px"
            v-model="forma.mtbf"
            placeholder="请输入平均无故障工作时间(MTBF)"
          />
        </el-form-item>
        <el-form-item label="平均修复时间(MTTR)" prop="mttr">
          <el-input
            style="width: 180px"
            v-model="forma.mttr"
            placeholder="请输入平均修复时间(MTTR)"
          />
        </el-form-item>
        <div class="divflex">
          <span class="leftx"></span>
          <span class="mainz">管理</span>
          <span class="rightx"></span>
        </div>
        <el-form-item label="区段" prop="zone">
          <el-input
            style="width: 180px"
            v-model="forma.zone"
            placeholder="请输入区段"
          />
        </el-form-item>
        <el-form-item label="工区" prop="workArea">
          <el-input
            style="width: 180px"
            v-model="forma.workArea"
            placeholder="请输入工区"
          />
        </el-form-item>
        <el-form-item label="人员" prop="user">
          <el-input
            style="width: 180px"
            v-model="forma.user"
            placeholder="请输入人员"
          />
        </el-form-item>
        <el-form-item label="备注">
          <el-input
            v-model="forma.remark"
            type="textarea"
            :autosize="{ minRows: 4, maxRows: 4 }"
            placeholder="请输入内容"
          ></el-input>
        </el-form-item>
      </el-form>
      <div class="divflex" v-if="title == '排水信息修改'">
        <span class="leftx"></span>
        <span class="mainz">修改历史</span>
        <span class="rightx"></span>
      </div>
      <el-table
        v-if="title == '排水信息修改'"
        :data="historyList"
        height="20vh"
        border
      >
        <el-table-column
          label="序号"
          type="index"
          min-width="80"
        ></el-table-column>
        <el-table-column
          label="指标名"
          prop="property"
          min-width="80"
        ></el-table-column>
        <el-table-column label="变更前指标值" prop="oldValue" min-width="110">
        </el-table-column>
        <el-table-column label="变更后指标值" prop="newValue" min-width="80">
        </el-table-column>
        <el-table-column label="变更时间" prop="createTime" min-width="80">
        </el-table-column>
        <el-table-column label="操作用户名" prop="user" min-width="80">
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script setup name="drainage">
import {
  insertManRailFacilityDrainageapi,
  selectManRailFacilityDrainageListapi,
  editManRailFacilityDrainageapi,
  deleteManRailFacilityDrainageByIdapi,
  selectManBasicRailwayListapi,
  selectManBasicUnitListapi,
  selectManBasicprogressTypeListapi,
  selectManBasicPropertyListapi,
  selectManRailEditRecordListapi,
} from "@/api/main/api.js";
import { useContent } from "@/mixin/index.js";
const {
  meansopen,
  meansFun,
  formam,
  closefun,
  resumeUpdate,
  deviceProblem,
  businessFinance,
} = useContent();
import means from "@/components/railmodle/means.vue";
defineExpose({ getList });
const emit = defineEmits(["parentCount"]);
import { reactive, ref, toRefs } from "vue";
const { proxy } = getCurrentInstance();
const loading = ref(true);
const title = ref("排水信息新增");
const open = ref(false);
const data = reactive({
  // 基础数据-单位数据表格数据
  drainageList: [],
  // 查询参数
  queryParams: {
    pageNum: "1",
    pageSize: "10",
    railwayId: "",
    railwayName: "",
    progressTypeId: "",
    progressType: "",
    startMileageNumber: "",
    endMileageNumber: "",
  },

  progressTypeobj: [],
  railwayNameobj: [],
  unitNameobj: [],
  // 表单参数
  forma: {},
  // 表单校验
  rules: {
    unitId: [
      {
        required: true,
        message: "单位名称不能为空",
        trigger: ["blur", "change"],
      },
    ],
    railwayId: [
      {
        required: true,
        message: "线路名称不能为空",
        trigger: ["blur", "change"],
      },
    ],
    progressTypeId: [
      {
        required: true,
        message: "上下行不能为空",
        trigger: ["blur", "change"],
      },
    ],
    startMileageNumber: [
      {
        required: true,
        message: "起点里程不能为空",
        trigger: ["blur", "change"],
      },
    ],
    endMileageNumber: [
      {
        required: true,
        message: "终点里程不能为空",
        trigger: ["blur", "change"],
      },
    ],
    sidelongTypeId: [
      { required: true, message: "侧别不能为空", trigger: ["blur", "change"] },
    ],
  },
  // 是否并行
  parallelOrNotobj: [
    {
      value: "是",
      label: "是",
    },
    {
      value: "否",
      label: "否",
    },
  ],
  editobj: {},
  railwayNamearr: [],
  progressTypearr: [],
  sidelongTypeobj: [],
  propertyList: [],
  drainageDitchTypeobj: [],
  structureTypeobj: [],
  historyList: [],
  selecttabList: [],
});
const {
  selecttabList,
  historyList,
  parallelOrNotobj,
  drainageDitchTypeobj,
  structureTypeobj,
  propertyList,
  sidelongTypeobj,
  railwayNamearr,
  progressTypearr,
  queryParams,
  forma,
  rules,
  drainageList,
  unitNameobj,
  railwayNameobj,
  editobj,
  progressTypeobj,
} = toRefs(data);
function updateproperyfun(row) {
  if (row == "起点") {
    if (forma.value.endMileageNumber) {
      if (
        Number(forma.value.startMileageNumber) >=
        Number(forma.value.endMileageNumber)
      ) {
        proxy.$modal.msgError("起点里程需要小于终点里程");
        forma.value.startMileageNumber = "";
      }
    }
  } else if (row == "终点") {
    if (
      Number(forma.value.endMileageNumber) <=
      Number(forma.value.startMileageNumber)
    ) {
      proxy.$modal.msgError("终点里程需要大于起点里程");
      forma.value.endMileageNumber = "";
    }
  }
}
//修改记录查询
function historyListfun() {
  selectManRailEditRecordListapi({ equipmentId: editobj.value.id }).then(
    (res) => {
      historyList.value = res.data;
    }
  );
}
function selectiontab(row) {
  selecttabList.value = row;
}
/** 导出按钮操作 */
function handleExport() {
  if (selecttabList.value.length == 0) {
    proxy.$modal.msgError("请选择设备");
    return;
  }
  const arrid = [];
  for (let i = 0; i < selecttabList.value.length; i++) {
    arrid.push(selecttabList.value[i].id);
  }
  proxy.download1(
    "facility-manage/railFacilityDrainage/exportExcel",
    arrid,
    `排水${new Date().getTime()}.xlsx`
  );
}
/** 查询基础数据-备轨数据列表 */
const pageNumparent = ref(undefined);
const pageSizeparent = ref(undefined);
/** 查询列表 */
function getList(pageNum, pageSize) {
  loading.value = true;
  if (pageNum != undefined || pageSize != undefined) {
    pageNumparent.value = pageNum;
    pageSizeparent.value = pageSize;
    queryParams.value.pageNum = pageNum == undefined ? 1 : pageNum;
    queryParams.value.pageSize = pageSize == undefined ? 10 : pageSize;
  } else {
    queryParams.value.pageNum =
      pageNumparent.value == undefined ? "1" : pageNumparent.value;
    queryParams.value.pageSize =
      pageSizeparent.value == undefined ? "10" : pageSizeparent.value;
  }
  selectManRailFacilityDrainageListapi(queryParams.value).then((res) => {
    if (res.code == 200) {
      drainageList.value = res.data;
      const xian = {};
      railwayNamearr.value = drainageList.value.reduce((next, item) => {
        xian[item.railwayName] == undefined
          ? (xian[item.railwayName] = true & next.push(item))
          : "";
        return next;
      }, []);
      const hang = {};
      progressTypearr.value = drainageList.value.reduce((next, item) => {
        hang[item.progressType] == undefined
          ? (hang[item.progressType] = true & next.push(item))
          : "";
        return next;
      }, []);
      loading.value = false;
      emit("parentCount", res.count);
    }
  });
}
getList();
//重置
function resetQuery() {
  queryParams.value = {
    railwayId: "",
    railwayName: "",
    progressTypeId: "",
    progressType: "",
    startMileageNumber: "",
    endMileageNumber: "",
  };
  getList();
}
/** 查询基础数据-单位数据列表 */
function getList1() {
  selectManBasicRailwayListapi({ hasDelete: 0 }).then((res) => {
    if (res.code == 200) {
      railwayNameobj.value = res.data;
    }
  });
}
getList1();
/** 查询基础数据-线名数据列表 */
function getList2() {
  selectManBasicUnitListapi({ hasDelete: 0 }).then((res) => {
    if (res.code == 200) {
      unitNameobj.value = res.data;
    }
  });
}
getList2();
/** 查询基础数据-行别数据列表 */
function getList3() {
  selectManBasicprogressTypeListapi({ hasDelete: 0 }).then((res) => {
    if (res.code == 200) {
      progressTypeobj.value = res.data;
    }
  });
}
getList3();
/** 查询基础数据-属性维护数据列表 */
function getList4() {
  selectManBasicPropertyListapi({ hasDelete: 0 }).then((res) => {
    if (res.code == 200) {
      propertyList.value = res.data;
      sidelongTypeobj.value = [];
      drainageDitchTypeobj.value = [];
      structureTypeobj.value = [];
      for (let i = 0; i < propertyList.value.length; i++) {
        if (propertyList.value[i].propertyType == "侧别") {
          sidelongTypeobj.value.push(propertyList.value[i]);
        }
        if (propertyList.value[i].propertyType == "排水沟类型") {
          drainageDitchTypeobj.value.push(propertyList.value[i]);
        }
        if (propertyList.value[i].propertyType == "结构类型") {
          structureTypeobj.value.push(propertyList.value[i]);
        }
      }
    }
  });
}
getList4();

// 取消按钮
function cancel() {
  open.value = false;
}
/** 搜索按钮操作 */
function handleQuery() {
  getList();
}
function clear() {
  forma.value = {
    unitName: "",
    railwayName: "",
    progressType: "",
    sidelongType: "",
    drainageDitchType: "",
    structureType: "",
    unitId: "",
    railwayId: "",
    progressTypeId: "",
    startMileage: "",
    endMileage: "",
    startMileageNumber: "",
    endMileageNumber: "",
    sidelongTypeId: "",
    parallelOrNot: "",
    drainageDitchTypeId: "",
    structureTypeId: "",
    drainageSlopeGradient: "",
    drainageDeepness: "",
    parapetDeepness: "",
    parapetWidth: "",
    parapetBottomWidth: "",
    strength: "",
    subcrustWidth: "",
    subcrustThickness: "",
    offsetAxis: "",
    ditchBottomExtent: "",
    wallStraightness: "",
    wallSlopeGradient: "",
    crossSectionSize: "",
    paveThickness: "",
    aspect: "",
    completionDate: "",
    healthIndex: "",
    hiddenDangerLevel: "",
    equipmentUsageFrequency: "",
    oee: "",
    mtbf: "",
    mttr: "",
    zone: "",
    workArea: "",
    user: "",
    hasDelete: "",
  };
}
/** 新增按钮操作 */
function handleAdd() {
  open.value = true;
  clear();
  title.value = "排水信息新增";
}
/** 修改按钮操作 */
function handleUpdate(row) {
  title.value = "排水信息修改";
  editobj.value = JSON.parse(JSON.stringify(row));
  forma.value = JSON.parse(JSON.stringify(row));
  historyListfun();
  open.value = true;
}
/** 提交按钮 */
function submitForm() {
  proxy.$refs["form"].validate((valid) => {
    if (valid) {
      if (forma.value.id != null) {
        const newforma = JSON.parse(JSON.stringify(forma.value));
        for (const key in editobj.value) {
          for (const keya in newforma) {
            if (
              key == keya &&
              editobj.value[key] == newforma[keya] &&
              key != "id"
            ) {
              Reflect.deleteProperty(newforma, keya);
            }
          }
        }
        if (
          newforma.startMileageNumber != undefined &&
          newforma.startMileageNumber != null
        ) {
          newforma.startMileageNumber =
            Math.round(newforma.startMileageNumber * 1000000) / 1000000;
        }
        if (
          newforma.endMileageNumber != undefined &&
          newforma.endMileageNumber != null
        ) {
          newforma.endMileageNumber =
            Math.round(newforma.endMileageNumber * 1000000) / 1000000;
        }
        if (Object.keys(newforma).length <= 1) {
          open.value = false;
        } else {
          editManRailFacilityDrainageapi(newforma).then((res) => {
            proxy.$modal.msgSuccess("修改成功");
            open.value = false;
            getList();
          });
        }
      } else {
        forma.value.startMileageNumber =
          Math.round(forma.value.startMileageNumber * 1000000) / 1000000;
        forma.value.endMileageNumber =
          Math.round(forma.value.endMileageNumber * 1000000) / 1000000;
        insertManRailFacilityDrainageapi(forma.value).then((res) => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  proxy.$modal
    .confirm("是否确认删除")
    .then(function () {
      return deleteManRailFacilityDrainageByIdapi({ id: row.id });
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => {});
}
</script>
<style scoped lang="scss">
.el-form--inline .el-form-item.formitemcla {
  margin-right: 5px !important;
}
</style>
